/**
 *
 */
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('wss', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateMultiOrderRequest {
  orderItems?: [ 
    {
      amount?: int32(name='Amount', example='1'),
      autoPay?: boolean(name='AutoPay', example='true'),
      autoRenew?: boolean(name='AutoRenew', example='false'),
      components?: [ 
        {
          key?: string(name='Key', example='RegionId'),
          value?: string(name='Value', example='cn-shanghai'),
        }
      ](name='Components'),
      period?: int32(name='Period', example='1'),
      periodUnit?: string(name='PeriodUnit', example='Year'),
      promotionId?: string(name='PromotionId', example='youhuiquan_promotion_option_id_for_blank'),
      resourceIds?: [ string ](name='ResourceIds'),
      resourceType?: string(name='ResourceType', description='This parameter is required.', example='DurationPackage'),
    }
  ](name='OrderItems'),
  orderType?: string(name='OrderType', example='create'),
  properties?: map[string]string(name='Properties'),
  resellerOwnerUid?: long(name='ResellerOwnerUid'),
}

model CreateMultiOrderShrinkRequest {
  orderItems?: [ 
    {
      amount?: int32(name='Amount', example='1'),
      autoPay?: boolean(name='AutoPay', example='true'),
      autoRenew?: boolean(name='AutoRenew', example='false'),
      components?: [ 
        {
          key?: string(name='Key', example='RegionId'),
          value?: string(name='Value', example='cn-shanghai'),
        }
      ](name='Components'),
      period?: int32(name='Period', example='1'),
      periodUnit?: string(name='PeriodUnit', example='Year'),
      promotionId?: string(name='PromotionId', example='youhuiquan_promotion_option_id_for_blank'),
      resourceIds?: [ string ](name='ResourceIds'),
      resourceType?: string(name='ResourceType', description='This parameter is required.', example='DurationPackage'),
    }
  ](name='OrderItems'),
  orderType?: string(name='OrderType', example='create'),
  propertiesShrink?: string(name='Properties'),
  resellerOwnerUid?: long(name='ResellerOwnerUid'),
}

model CreateMultiOrderResponseBody = {
  orderIds?: [ long ](name='OrderIds'),
  requestId?: string(name='RequestId', example='833C4D2C-09C7-5CE6-8159-06758B964970'),
}

model CreateMultiOrderResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateMultiOrderResponseBody(name='body'),
}

/**
 * @param tmpReq CreateMultiOrderRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateMultiOrderResponse
 */
async function createMultiOrderWithOptions(tmpReq: CreateMultiOrderRequest, runtime: $RuntimeOptions): CreateMultiOrderResponse {
  tmpReq.validate();
  var request = new CreateMultiOrderShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!$isNull(tmpReq.properties)) {
    request.propertiesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.properties, 'Properties', 'json');
  }
  var query = {};
  if (!$isNull(request.orderItems)) {
    query['OrderItems'] = request.orderItems;
  }
  if (!$isNull(request.orderType)) {
    query['OrderType'] = request.orderType;
  }
  if (!$isNull(request.propertiesShrink)) {
    query['Properties'] = request.propertiesShrink;
  }
  if (!$isNull(request.resellerOwnerUid)) {
    query['ResellerOwnerUid'] = request.resellerOwnerUid;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateMultiOrder',
    version = '2021-12-21',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @param request CreateMultiOrderRequest
 * @return CreateMultiOrderResponse
 */
async function createMultiOrder(request: CreateMultiOrderRequest): CreateMultiOrderResponse {
  var runtime = new $RuntimeOptions{};
  return createMultiOrderWithOptions(request, runtime);
}

model DescribeDeliveryAddressResponseBody = {
  addresses?: [ 
    {
      area?: {
        areaId?: long(name='AreaId', example='33****'),
        areaName?: string(name='AreaName'),
      }(name='Area'),
      city?: {
        cityId?: long(name='CityId', example='33****'),
        cityName?: string(name='CityName'),
      }(name='City'),
      contacts?: string(name='Contacts', example='Alice'),
      defaultAddress?: boolean(name='DefaultAddress', example='true'),
      detail?: string(name='Detail'),
      mobile?: string(name='Mobile', example='1381111****'),
      postalCode?: string(name='PostalCode', example='03****'),
      province?: {
        provinceId?: long(name='ProvinceId', example='330000'),
        provinceName?: string(name='ProvinceName'),
      }(name='Province'),
      town?: {
        townId?: long(name='TownId', example='3001****'),
        townName?: string(name='TownName'),
      }(name='Town'),
    }
  ](name='Addresses'),
  requestId?: string(name='RequestId', example='72481C12-69AB-5CE1-8A35-A8EFA921****'),
  totalCount?: int32(name='TotalCount', example='6'),
}

model DescribeDeliveryAddressResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDeliveryAddressResponseBody(name='body'),
}

/**
 * @param request DescribeDeliveryAddressRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeDeliveryAddressResponse
 */
async function describeDeliveryAddressWithOptions(runtime: $RuntimeOptions): DescribeDeliveryAddressResponse {
  var req = new OpenApiUtil.OpenApiRequest{};
  var params = new OpenApiUtil.Params{
    action = 'DescribeDeliveryAddress',
    version = '2021-12-21',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @return DescribeDeliveryAddressResponse
 */
async function describeDeliveryAddress(): DescribeDeliveryAddressResponse {
  var runtime = new $RuntimeOptions{};
  return describeDeliveryAddressWithOptions(runtime);
}

model DescribePackageDeductionsRequest {
  endTime?: long(name='EndTime'),
  instanceIds?: [ string ](name='InstanceIds'),
  packageIds?: [ string ](name='PackageIds'),
  pageNum?: int32(name='PageNum', example='1'),
  pageSize?: int32(name='PageSize', example='100'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='CorePackage'),
  startTime?: long(name='StartTime'),
}

model DescribePackageDeductionsResponseBody = {
  deductions?: [ 
    {
      cpu?: int32(name='Cpu', example='4'),
      desktopId?: string(name='DesktopId', example='ecd-6wye9optu0kag****'),
      desktopName?: string(name='DesktopName', example='DemoComputer'),
      desktopType?: string(name='DesktopType', example='eds.enterprise_office.4c8g'),
      endTime?: string(name='EndTime', example='2024-07-31T03:00Z'),
      instanceState?: string(name='InstanceState', example='Deleted'),
      memory?: long(name='Memory', example='8192'),
      osType?: string(name='OsType', example='Windows'),
      regionId?: string(name='RegionId', example='cn-hangzhou'),
      resourceType?: string(name='ResourceType'),
      staTime?: string(name='StaTime', example='2024-07-31T02:00Z'),
      usedCoreTime?: float(name='UsedCoreTime', example='4.0'),
      usedTime?: long(name='UsedTime', example='3600'),
    }
  ](name='Deductions'),
  pageNum?: int32(name='PageNum', example='1'),
  pageSize?: int32(name='PageSize', example='100'),
  requestId?: string(name='RequestId', example='833C4D2C-09C7-5CE6-8159-06758B964970'),
  totalCount?: long(name='TotalCount', example='100'),
  totalUsedCoreTime?: float(name='TotalUsedCoreTime'),
  totalUsedTime?: long(name='TotalUsedTime'),
}

model DescribePackageDeductionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribePackageDeductionsResponseBody(name='body'),
}

/**
 * @summary 查询核时包抵扣明细
 *
 * @param request DescribePackageDeductionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribePackageDeductionsResponse
 */
async function describePackageDeductionsWithOptions(request: DescribePackageDeductionsRequest, runtime: $RuntimeOptions): DescribePackageDeductionsResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!$isNull(request.instanceIds)) {
    query['InstanceIds'] = request.instanceIds;
  }
  if (!$isNull(request.packageIds)) {
    query['PackageIds'] = request.packageIds;
  }
  if (!$isNull(request.pageNum)) {
    query['PageNum'] = request.pageNum;
  }
  if (!$isNull(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!$isNull(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!$isNull(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DescribePackageDeductions',
    version = '2021-12-21',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询核时包抵扣明细
 *
 * @param request DescribePackageDeductionsRequest
 * @return DescribePackageDeductionsResponse
 */
async function describePackageDeductions(request: DescribePackageDeductionsRequest): DescribePackageDeductionsResponse {
  var runtime = new $RuntimeOptions{};
  return describePackageDeductionsWithOptions(request, runtime);
}

model ModifyInstancePropertiesRequest {
  instanceId?: string(name='InstanceId', example='mdp-0c62ayep0nk4v****'),
  instanceIds?: [ string ](name='InstanceIds'),
  key?: string(name='Key', example='PackageUsedUpStrategy'),
  resourceType?: string(name='ResourceType', description='This parameter is required.', example='DurationPackage'),
  value?: string(name='Value', example='Postpaid'),
}

model ModifyInstancePropertiesResponseBody = {
  requestId?: string(name='RequestId', example='833C4D2C-09C7-5CE6-8159-06758B964970'),
}

model ModifyInstancePropertiesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyInstancePropertiesResponseBody(name='body'),
}

/**
 * @param request ModifyInstancePropertiesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyInstancePropertiesResponse
 */
async function modifyInstancePropertiesWithOptions(request: ModifyInstancePropertiesRequest, runtime: $RuntimeOptions): ModifyInstancePropertiesResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!$isNull(request.instanceIds)) {
    query['InstanceIds'] = request.instanceIds;
  }
  if (!$isNull(request.key)) {
    query['Key'] = request.key;
  }
  if (!$isNull(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!$isNull(request.value)) {
    query['Value'] = request.value;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ModifyInstanceProperties',
    version = '2021-12-21',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @param request ModifyInstancePropertiesRequest
 * @return ModifyInstancePropertiesResponse
 */
async function modifyInstanceProperties(request: ModifyInstancePropertiesRequest): ModifyInstancePropertiesResponse {
  var runtime = new $RuntimeOptions{};
  return modifyInstancePropertiesWithOptions(request, runtime);
}

